cmake_minimum_required(VERSION 3.29)
project(Supervisor)

set(CMAKE_CXX_STANDARD 23)
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
    # 设置 UTF-8 编码
    add_compile_options(/utf-8)
endif ()
add_definitions(-D_WIN32_WINNT=0x0A00)
#set(CMAKE_BUILD_TYPE Release)

message(STATUS "HOME DIR: $ENV{CONCPP_HOME}")

include(cmake/xrepo.cmake)
xrepo_package("boost" CONFIGS system=true,thread=true,date_time=true,regex=true,serialization=true,locale=true,coroutine=true,openssl=true,stacktrace=true,cmake=false DIRECTORY_SCOPE)
xrepo_package("spdlog" CONFIGS header_only=false,std_format=true,cxxflags='/utf-8' DIRECTORY_SCOPE)

add_executable(Supervisor main.cpp
        common/logger.hpp
        common/macros.hpp
        common/concepts.hpp
        common/base.hpp
        common/utils.hpp
        common/error.hpp
        common/errcode.hpp
        common/serializer/reader.hpp
        common/serializer/writer.hpp
        common/serializer.hpp
        common/types.h
        protocol/message/jtt808_header.hpp
        protocol/message/jtt808_body.hpp
        protocol/message/jtt808_packet.hpp
        protocol/tools/validate.hpp
        protocol/tools/message_factory.hpp
        protocol/message/terminal/common_response.hpp
        protocol/message/platform/common_response.hpp
        protocol/message/terminal/heartbeat.hpp
        protocol/message/empty_body.hpp
        protocol/message/bodies_pch.hpp
        protocol/message/terminal/server_time_req.hpp
        protocol/message/platform/server_time_res.hpp
        protocol/message/platform/retransfer_segmentation.hpp
        protocol/message/terminal/retransfer_segmentation.hpp
        protocol/message/terminal/registeration.hpp
        protocol/message/platform/register_response.hpp
        protocol/message/terminal/logout.hpp
        protocol/message/terminal/verification.hpp
        protocol/tools/packet_factory.hpp
        protocol/message.hpp
        protocol/message/partial_body.hpp
        network/waitable.hpp
        network/gateway.hpp
        network/common.hpp
        network/server.hpp
        network/client.hpp
        network/packet_handler.hpp
        common/storage.hpp
        common/entity/terminal_registration.hpp
        common/entity/terminal.hpp
        common/entity/car.hpp
        common/entity/entity.hpp
)

# ���� MySQL Connector/C++ ��·��
set(mysql-concpp_DIR "$ENV{CONCPP_HOME}")
if (${CMAKE_BUILD_TYPE} STREQUAL "Release")
    message(STATUS "Release Build")
    find_package(mysql-concpp REQUIRED)
else()
    message(STATUS "Debug Build")
    find_package(mysql-concpp REQUIRED debug)
endif ()




target_include_directories(Supervisor PRIVATE
        ${CMAKE_CURRENT_SOURCE_DIR}
        ${MYSQL_CONCPP_INCLUDE_DIR}
)


target_link_libraries(Supervisor mysql::concpp-static)


add_compile_definitions(SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE)
include(cmake/BuildConfig.cmake)

link_libraries(ws2_32)